package pl.easyshop.core.model;

import java.io.Serializable;

import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.SequenceGenerator;
import javax.persistence.Version;

/**
 * Base class for all data model.
 * 
 * @author Pawel Witkowski
 */
@MappedSuperclass
public abstract class AbstractBaseModel implements Serializable {

	/** Unique serialization identifier. */
	private static final long serialVersionUID = -7423820305630115728L;

	/** Object identifier. */
	@Id
	@SequenceGenerator(sequenceName = "model_seq", name = "model_seq", allocationSize = 1, initialValue = 1)
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator="model_seq")
	private Long id;
	
	/** Version of object (optimistic lock). */
	@Version
	private Long version;

	/**
	 * Get id property value.
	 * @return the id
	 */
	public Long getId() {
		return id;
	}

	/**
	 * Set id property value.
	 * @param id the id to set
	 */
	public void setId(Long id) {
		this.id = id;
	}

	/**
	 * Get version property value.
	 * @return the version
	 */
	public Long getVersion() {
		return version;
	}

	/**
	 * Set version property value.
	 * @param version the version to set
	 */
	public void setVersion(Long version) {
		this.version = version;
	}
}
